package ae.pcfc.cldos.online.common.strategy.transfer.providers;

import ae.pcfc.cldos.online.common.clddb.domain.AddressDetail;
import ae.pcfc.cldos.online.common.clddb.domain.AppMetaData;
import ae.pcfc.cldos.online.common.clddb.domain.EmployeeDetail;
import ae.pcfc.cldos.online.common.clddb.domain.PassportDetail;
import ae.pcfc.cldos.online.common.clddb.domain.PersonalDetail;
import ae.pcfc.cldos.online.common.clddb.domain.VisitVisa;
import ae.pcfc.cldos.online.common.strategy.transfer.BaseTransferStrategy;
import ae.pcfc.cldos.online.common.vo.TransferDataVO;
import ae.pcfc.cldos.online.net.service.vo.AppMetaDataVO;
import ae.pcfc.cldos.online.net.service.vo.ApplicationDataVO;
import ae.pcfc.cldos.online.net.service.vo.EmployeeVO;
import ae.pcfc.cldos.online.net.service.vo.PersonVO;
import ae.pcfc.cldos.online.net.service.vo.VisitVisaDataVO;

/**
 * 
 * @author akhader
 *
 */
public class NewVisitVisaTransferStrategyImpl extends BaseTransferStrategy {

	public String transferAppDateToOfflineSystem(TransferDataVO transferDataVO) {
		
		ApplicationDataVO applicationDataVO = new ApplicationDataVO();
		
		AppMetaData appMetaData = transferDataVO.getAppMetaData();
		EmployeeDetail employeeDetail = appMetaData.getEmployeeDetail();
		AddressDetail addressDetail = employeeDetail.getAddressDetail();
		PassportDetail passportDetail = employeeDetail.getPassportDetail();
		PersonalDetail personalDetail = employeeDetail.getPersonalDetail();
		VisitVisa visitVisa = appMetaData.getVisitVisa();
		
		AppMetaDataVO appMetaDataVO = new AppMetaDataVO();
		mapper.map(appMetaData, appMetaDataVO);
		mapper.map(employeeDetail, appMetaDataVO);
		applicationDataVO.setAppMetaDataVO(appMetaDataVO);
		
		EmployeeVO employeeVO = new EmployeeVO();
		mapper.map(employeeDetail, employeeVO);
		employeeVO.setCompanyLicenseNo(transferDataVO.getCompanyLicenseNo());
		mapper.map(addressDetail, employeeVO);
		applicationDataVO.setEmployeVO(employeeVO);
		
		PersonVO personVO = new PersonVO();
		mapper.map(employeeDetail, personVO);
		mapper.map(passportDetail, personVO);
		mapper.map(personalDetail, personVO);
		mapper.map(addressDetail, personVO);
		applicationDataVO.setPersonVO(personVO);
		
		VisitVisaDataVO visaDataVO = new VisitVisaDataVO();
		mapper.map(visitVisa, visaDataVO);
		applicationDataVO.setVisitVisaDataVO(visaDataVO);
		
		applicationDataVO.setAttachmentVOList(getAttachmentsList(appMetaData));
		
		return netDataTransferService.transferNewVisitVisaData(applicationDataVO);
	}
}
